﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using mbine.msgc.tool;
namespace mbine.msgc.model
{
    public class CThread
    {
        public string Key { get; set; }
        public bool IsStar { get; set; }
        public bool IsOpen { get; set; }
        public string Name { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public List<IUser> Members { get; set; }
        public List<CRelayMessage> Messages { get; set; }

        public CThread()
        {
            Members = new List<IUser>();
            Messages = new List<CRelayMessage>();
            Key = CTools.MakeRoomKey();
        }

        public CThread(string _key)
        {
            Members = new List<IUser>();
            Messages = new List<CRelayMessage>();
            Key = _key;
        }

        public void Add(CRelayMessage _msg)
        {
            Messages.Add(_msg);
        }

        public void Add(IUser _user)
        {
            if(!Members.Contains(_user))
                Members.Add(_user);
        }

        public void Add(List<IUser> _users)
        {
            foreach (IUser user in _users)
            {
                Add(user);
            }
        }
    }
}
